<template>
  <div class="container">
    <div>
      <div>
        <span @click="$router.back(-1)"
          class="back">{{$t('page.ReturnList')}}</span> >
        {{$route.query.name}}（{{$route.query.time}}）
      </div>
    </div>

    <!-- 内容 -->
    <div class="container-body">
      <div style="width:60%;float:left;">
        <img :src="stepOneList.img" alt=""
          style="margin-bottom:30px;width:100%;" />
      </div>

      <div
        style="width:40%;float:left;padding-left:50px">
        <div style="text-align:right;margin: -20px 0 20px;">
          <el-button
            type="text"
            @click="downloadExl()" 
            size="medium">
            {{$t('page.exportTable')}}
          </el-button>
        </div>
        <table id="table-2" width="100%">
          <tr>
            <td width="50%">
              {{$t('page.formula')}}
            </td>
            <td>
              <!-- <span 
                v-for="(item, index) in stepOneList.formulas" 
                :key="index">{{item}}</span>
                <br/> -->
              {{stepOneList.formula}}
            </td>
          </tr>
          <tr
            v-if="stepOneList.struct && stepOneList.struct.rsquare">
            <td width="50%">
              {{$t('page.Rsquare')}}
            </td>
            <td>
              {{stepOneList.struct.rsquare}}
            </td>
          </tr>
          <tr v-if="stepOneList.params">
            <td width="50%">
              {{$t('page.parameter')}}</td>
            <td>
              <template
                v-for="(value, key, index) in stepOneList.params">
                  <p class="data-item">{{key}}：{{value}} <br> </p>
              </template>
            </td>
          </tr>

          <tr v-if="!stepOneList.exportConcentration">
            <td width="50%">{{$t('page.label')}}</td>
            <td>
              <template
                v-for="(value, key) in stepOneList.ndResult">
                <p
                  class="data-item">{{key}}：{{value}} <br> </p>
              </template>
            </td>
          </tr>
        </table>
      </div>

      <holesTable 
        v-if="stepOneList.exportConcentration"
        :noDisabled="data.Odname"
        :unKnowResult="stepOneList.unKnowresult"
        @inputHoles="inputHoles"
        :exportConcentration="stepOneList.exportConcentration">
      </holesTable>
    </div>
  </div>
</template>

<script>
import { fetchHistoryDetail } from "@/api/table";
import { getStore } from '@/utils/common'
import holesTable from "@/components/96HolesTable";


export default {
  name: "",
  data() {
    return {
      loading: true,
      stepOneList: {
        params: {},
        struct: {},
        ng: "",
        x: "",
      },
      data: {},
      isShowLog: false, //是否显示公式
      isShowStepOne: false, //是否显示第一步表格
      isShowUpload: true,
      isShowUploadtxt: false,
      uploadFile: {},
      exlName: "", //下载表格名
      isShowPer: false,
      percentage: 0,
      customColor: "#e6a23c",
      concentration: [],
    };
  },
  components: {
    holesTable,
  },
  mounted() {
    this.getDetail();
  },
  methods: {
    async getDetail() {
      const res = await fetchHistoryDetail({
        id: this.$route.query.id,
      });
      this.stepOneList = JSON.parse(res.data[0].resultData);
      console.log(this.stepOneList);
      this.loading = false;
    },
    inputHoles(value) {
      this.concentration = value;
    },
    downloadExl() {
      const lang = getStore('spr-lang')
      const href = `${process.env.BASE_URL}receive/download/excel/1/${lang}/${this.stepOneList.uuid}`
      window.open(href, '_blank')
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  padding: 20px;
}
.back {
  color: #028cdf;
  cursor: pointer;
}
table {
  border-collapse: collapse;
  text-align: center;
  white-space: nowrap;
  margin-bottom: 20px;
}
#table-2 {
  border-bottom-width: 1px;
  border-bottom-style: solid;
  border-bottom-color: #000;
}
#table-2 tr {
  border: 1px solid #000 !important;
}

#table-2 td:first-child {
  border-left: 1px solid #000;
}

/* Padding and font style */
#table-2 td,
#table-2 th {
  padding: 10px 15px;
  font-size: 12px;
  font-family: Verdana;
  border-right-width: 1px;
  border-right-style: solid;
}

.data-item {
  text-align: left;
  padding-left: 40px;
}
</style>